<?php
require_once('../../../config.php');

if($_POST){
	$attempt = $_POST['attempt'];
	$question = $_POST['question'];

	//create zip file
	//exec("zip -r ");
	
	//kirim request ke middle ware plain, sama seperti di DG
	
	//tulis ke mdl_question_sourcecode_files, untuk simpan zipped file
	//file, mime, name, timestamp, request_id, attempt, question
	print_r($_POST);
	//echo $_POST['content'];
	
	$dir = ""; //mkdirs
	
	if(isset($_POST['files'])){
		$file_count = count($_POST['files']);
		for($i=0,$n=$file_count; $i<$n; ++$i){
			$file_name = $_POST['files'][$i]['fileName'];
			$content = $_POST['files'][$i]['content'];
			file_put_contents($dir . "/" . $file_name, stripslashes($content));
		}		
	}else{
		echo 'File not specified';
	}
}

?>
